//
//  LeaingMessageTableViewCell.m
//  兼职页面
//
//  Created by kuiyuan liang on 2021/5/25.
//

#import "LeaingMessageTableViewCell.h"
#import "CommonUtil.h"
#import "PersonView.h"
#import "ReplayViewController.h"
#import "ReportAlert.h"
#import "FeedContentView.h"
#import "ReplayView.h"


@interface LeaingMessageTableViewCell()

@property (strong, nonatomic) PersonView * infoView;
@property (strong, nonatomic) FeedContentView * feedView;
@property (strong, nonatomic) ReplayView * replayView;



@end


@implementation LeaingMessageTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.infoView];
        [self.contentView addSubview:self.feedView];
        [self.contentView addSubview:self.replayView];

    }
    return self;
}





-(void)setModel:(MessageModel *)model{
    _model = model;
    
    self.feedView.superVC  = self.superVC;
    self.replayView.superVC = self.superVC;
    self.feedView.model = model;
    
    self.feedView.height = model.feedHeight;
    self.replayView.top = self.feedView.bottom + AD(15);
    self.replayView.height = model.replayHeight;
    self.replayView.model = model;
    if (model.isDetail) {
        
        [self.infoView addSubview:self.feedView.replayBtn];
        [self.infoView addSubview:self.feedView.reportBtn];
        
        self.infoView.iconImageView.size = CGSizeMake(AD(30), AD(30));
        self.infoView.iconImageView.top = AD(5);
        self.infoView.iconImageView.layer.cornerRadius = AD(15);
        
        self.feedView.reportBtn.left = AD(230);
        self.feedView.reportBtn.centerY = self.infoView.height/2;
        
        self.feedView.replayBtn.left = self.feedView.reportBtn.right + AD(10);
        self.feedView.replayBtn.centerY = self.infoView.height/2;
    }

    if (model.replayList.count > 0) {
        self.replayView.hidden = false;
    }else{
        self.replayView.hidden = YES;
    }
    
    
}

- (void)replayBtnClick:(UIButton *)sender{
    NSLog(@"回复");
    [self.superVC presentViewController:[ReplayViewController new] animated:YES completion:nil];
}

- (void)reportBtnClick:(UIButton *)sender{
    NSLog(@"举报");
    BaseAlert *alert = [HudFactory creatHudWithType:@"ReportAlert"];
    [alert show];
}


#pragma mark - lazy
-(PersonView *)infoView{
    if (!_infoView) {
        _infoView = [[PersonView alloc] initWithFrame:CGRectMake(0, AD(20), SCREEN_WIDTH, AD(40))];
    }
    return _infoView;
}

-(FeedContentView *)feedView{
    if (!_feedView) {
        _feedView = [[FeedContentView alloc] initWithFrame:CGRectMake(0, _infoView.bottom, SCREEN_WIDTH, 0)];
        [_feedView.replayBtn addTarget:self action:@selector(replayBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [_feedView.reportBtn addTarget:self action:@selector(reportBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        //_feedView.backgroundColor = [UIColor redColor];
    }
    return _feedView;
}

-(ReplayView *)replayView{
    if (!_replayView) {
        _replayView = [[ReplayView alloc] initWithFrame:CGRectMake(AD(70), 0, SCREEN_WIDTH-AD(100), 0)];
       // _replayView.backgroundColor = [UIColor blueColor];
    }
    return _replayView;
}

@end
